<!DOCTYPE html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>职位管理</title>
    <link href="../../../static/css/style.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" src="../../../static/js/jquery.js"></script>
</head>
<script type="text/javascript">
    //数据回显
    $(function () {
        var jobId = JSON.parse(localStorage.getItem("sysjobId"));
        $.ajax({
            type: "post",
            url: "/job/jobDetail",
            data: {jobId: jobId},
            dataType: "JSON",
            success: function (rm) {
                $("#jobId").val(rm.data.jobId);
                $("#jobName").val(rm.data.jobName);
                var deptId = rm.data.jobDeptId;
                //部门查询
                $.ajax({
                    type: "post",
                    url: "/dept/deptList",
                    data: {},
                    dataType: "JSON",
                    success: function (rm) {
                        var deptstr = '<option value="">请选择</option>';
                        for (let i = 0; i < rm.data.length; i++) {
                            if(deptId == rm.data[i].deptId){
                                deptstr += '<option selected="selected" value="' + rm.data[i].deptId + '">' + rm.data[i].deptName + '</option>\n';
                            }else {
                                deptstr += '<option value="' + rm.data[i].deptId + '">' + rm.data[i].deptName + '</option>\n';
                            }
                        }
                        $("#jobDeptId").html(deptstr);
                    },
                    error: function (rm) {
                        alert(rm.msg)
                    }
                });
            }
        });
    });

    function jobUpdateSave() {
        $.ajax({
            type: "post",
            url: "/job/updateJob",
            data: $("#Form").serializeArray(),
            traditional: true,
            async: true,
            dataType: "JSON",
            success: function () {
                window.location.href = "findByPage";
            },
            error: function (rm) {
                alert(rm.msg);
            }
        });
    }
</script>
<body>
<form id="Form">
    <div class="place"><span>位置：</span>
        <ul class="placeul">
            <li><a href="../job/findByPage">系统管理</a></li>
            <li><a href="../job/findByPage">职位管理</a></li>
            <li><a href="../job/positionUpdate">修改</a></li>
        </ul>
    </div>
    <div class="formbody">
        <div class="formtitle"><span>职位信息</span></div>
        <ul class="forminfo">
            <li>
                <input name="jobId" id="jobId" type="hidden" value="001" class="dfinput" readonly/>
            </li>
            <li>
                <label>职位名称</label>
                <input name="jobName" id="jobName" type="text" value="高级工程师" class="dfinput"/>
                <i>必填，不能超过30个字符</i>
            </li>
            <li><label>所属部门：</label>
                <select class="dfselect" name="jobDeptId" id="jobDeptId">
                    <option value="">请选择部门</option>
                    <option value="" selected="selected">研发</option>
                    <option value="">销售</option>
                    <option value="">财务</option>
                </select>
            </li>
            <li>
                <label>&nbsp;</label>
                <input name="" type="button" class="btn" onclick="jobUpdateSave()" value="确认保存"/>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <input name="" type="button" class="btn" value="返回" onclick="window.history.go(-1);"/>
            </li>
        </ul>
    </div>
</form>
</body>
